package DataBase;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Vector;

public class AddNewDiscountToTable {
	
	private Vector<String> discount;
	private int status=0;
	
	public AddNewDiscountToTable(Vector<String> discount)
	{
		this.discount=discount;
	}
	
	public void saveNewDiscount()
	{
		SQLConnection sc=new SQLConnection();
		
		try {
		    
			PreparedStatement ps = sc.getConnection().prepareStatement("INSERT INTO discount_table (orderId,amount,type) values(?,?,?);");	
			sc.getConnection().setAutoCommit(false);
			ps.setInt(1,Integer.parseInt(discount.get(0)));
			ps.setInt(2,Integer.parseInt(discount.get(1)));
			ps.setString(3,(discount.get(2)));
			ps.executeUpdate();
			sc.getConnection().commit();
			ps.close();
			status=1;	
		}
		
		catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	         	}
	public int getStatus() {
		return status;
	}





	public void setStatus(int status) {
		this.status = status;
	}

}
